import {defineStore} from "pinia";
import {Ref, ref, UnwrapRef} from "vue";


export const mainStore = defineStore('main', () => {
    const userName: Ref<UnwrapRef<string>> = ref<string>('')
    const account: Ref<UnwrapRef<string>> = ref<string>('')
    const nowInfo: Ref<UnwrapRef<string>> = ref<string>('')
    const token: Ref<UnwrapRef<string>> = ref<string>('')
    const refreshToken: Ref<UnwrapRef<string>> = ref<string>('')
    const auth: Ref<UnwrapRef<string>> = ref<string>('')
    const text: Ref<UnwrapRef<string>> = ref<string>('')
    const loginStatus: Ref<UnwrapRef<boolean>> = ref<boolean>(false)

    const setter_account = (value: string) => {
        account.value = value
    }
    const setter_loginStatus = (value: boolean): any => {
        loginStatus.value = value
    }
    const getter_loginStatus = (): boolean => loginStatus.value
    const setter_userName = (value: string) => {
        userName.value = value
    }
    const getter_userName = () => userName.value
    const setter_auth = (value: string) => {
        auth.value = value
    }

    return {
        userName, account, nowInfo, token, refreshToken, auth, text, loginStatus,
        setter_account, setter_loginStatus, setter_userName, setter_auth,
        getter_loginStatus, getter_userName
    }
})
